package com.sks.bean.pojo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

/**
 * MetroStation entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "metro_station", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }) })
public class MetroStation implements java.io.Serializable {

	// Fields

	private Integer stationId;
	private Metro metroByMetroId1;
	private Metro metroByMetroId;
	private String name;
	private Boolean isIntersect;
	private String remark;
	private Integer metroId;
	private Integer metroId1;

	// Constructors

	/** default constructor */
	public MetroStation() {
	}

	/** minimal constructor */
	public MetroStation(Integer stationId, String name, Boolean isIntersect) {
		this.stationId = stationId;
		this.name = name;
		this.isIntersect = isIntersect;
	}

	/** full constructor */
	public MetroStation(Integer stationId, Metro metroByMetroId1,
			Metro metroByMetroId, String name, Boolean isIntersect,
			String remark) {
		this.stationId = stationId;
		this.metroByMetroId1 = metroByMetroId1;
		this.metroByMetroId = metroByMetroId;
		this.name = name;
		this.isIntersect = isIntersect;
		this.remark = remark;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "stationId", unique = true, nullable = false, insertable = true, updatable = true)
	public Integer getStationId() {
		return this.stationId;
	}

	public void setStationId(Integer stationId) {
		this.stationId = stationId;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "metroId1", unique = false, nullable = true, insertable = true, updatable = true)
	public Metro getMetroByMetroId1() {
		return this.metroByMetroId1;
	}

	public void setMetroByMetroId1(Metro metroByMetroId1) {
		this.metroByMetroId1 = metroByMetroId1;
		if (null != metroByMetroId1) {
			this.setMetroId1(metroByMetroId1.getMetroId());
		}
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "metroId", unique = false, nullable = true, insertable = true, updatable = true)
	public Metro getMetroByMetroId() {
		return this.metroByMetroId;
	}

	public void setMetroByMetroId(Metro metroByMetroId) {
		this.metroByMetroId = metroByMetroId;
		if (null != metroByMetroId) {
			this.setMetroId(metroByMetroId.getMetroId());
		}
	}

	@Column(name = "name", unique = true, nullable = false, insertable = true, updatable = true, length = 40)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "isIntersect", unique = false, nullable = false, insertable = true, updatable = true)
	public Boolean getIsIntersect() {
		return this.isIntersect;
	}

	public void setIsIntersect(Boolean isIntersect) {
		this.isIntersect = isIntersect;
	}

	@Column(name = "remark", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Transient
	public Integer getMetroId() {
		return metroId;
	}

	public void setMetroId(Integer metroId) {
		this.metroId = metroId;
	}

	@Transient
	public Integer getMetroId1() {
		return metroId1;
	}

	public void setMetroId1(Integer metroId1) {
		this.metroId1 = metroId1;
	}
	
	@Transient
	public String getMetroName() {
		if (null != this.getMetroByMetroId()) {
			return this.getMetroByMetroId().getName();
		}
		if (null != this.getMetroByMetroId1()) {
			return this.getMetroByMetroId1().getName();
		}
		return null;
	}
}